package com.societyGames.flashForms
{
import flash.display.Sprite;
import flash.text.TextField;

public class TextButton extends ThreeStateButton
{
  private var _desiredWidth:Number;
  private var _desiredHeight:Number;
  private var _textField:TextField;
  private var _centerScaleTextFieldContainer:CenterScaleTextFieldContainer;

  public function TextButton(textField:TextField, up:Sprite, over:Sprite = null, down:Sprite = null)
  {
    super(up, over, down);
    this._textField = textField;

    this._textField.width = this.width;
    this._textField.height = this.height;

    _centerScaleTextFieldContainer = new CenterScaleTextFieldContainer();
    _centerScaleTextFieldContainer.textField = this._textField;
    this.addChild(_centerScaleTextFieldContainer);
  }

  public override function set height(value:Number):void
  {
    super.height = value;
    this._desiredHeight = value;
    _centerScaleTextFieldContainer.height = value;
  }

  public override function set width(value:Number):void
  {
    super.width = value;
    this._desiredWidth = value;
    this._textField.width = value;
    _centerScaleTextFieldContainer.width = value;
  }

  public function set text(value:String):void
  {
    this._textField.text = value;
  }

  public function get text():String
  {
    return this._textField.text;
  }
}
}